
$.fn.sumTbCol = function(colIndex){
	var trs = this.children().children();
	var sum = 0.0;
	for(var i=1; i<trs.length; i++){
		sum += parseFloat(trs.eq(i).children().eq(colIndex).text());
	}
	return sum.toFixed(2);
};
//对象是否存在
 function isObj(str)
 {
  if(str==null||typeof(str)=='undefined')
   return false;
  return true;
 }
 
function showMsg(str,imgType){
	if(!isObj(imgType)){
		imgType = 12;
	}
	top.$.layer({
		area : ['auto','auto'],
		dialog : {msg:str, type : imgType}	
	});
}

function selfMsg(str,imgType){
	if(!isObj(imgType)){
		imgType = 12;
	}
	$.layer({
		area : ['auto','auto'],
		dialog : {msg:str, type : imgType}	
	});
}

/** 打开加载页面*/
function openLoadWindown() {
	parent.layer.load(0);
}
/** 关闭加载页面*/
function closeLoadWindow() {
	parent.layer.loadClose();
}

function showDefinedWindow(url,title,width,height,closeCallback){
	if(title==undefined){
		title = "详情页面";
	}
	if(width==undefined){
		width = 1024;
	}
	if(height==undefined){
		height = $(parent.window).height()*0.85;
	}
	var offset = ($(parent.window).height()-height)/2;
	
	if(parseFloat(width)>parseFloat(1024)){
		width = 1024;
	}
	if($(parent.window).height()<=height){
		height = $(parent.window).height()*0.85;
		offset = ($(parent.window).height()-height)/2;
	}
	showDlg(url,title,width,height,offset,closeCallback);
}

function showDlgDefault(url,title,width,height,closeCallback){
	if(title==undefined){
		title = "详情页面";
	}
	if(width==undefined){
		width = 1024;
	}
	if(height==undefined){
		height = $(parent.window).height()*0.85;
	}
	var offset = ($(parent.window).height()-height)/2;
	
	if(parseFloat(width)>parseFloat(1024)){
		width = 1024;
	}
	if($(parent.window).height()<=height){
		height = $(parent.window).height()*0.85;
		offset = ($(parent.window).height()-height)/2;
	}
	showDlg(url,title,width,height,offset,closeCallback);
}
//$(function() {
//    $( "#layui-layer1" ).resizable();alert();
//  });
function showDlg(url,title,width,height,offset,closeCallback){
	parent.layer.open({
		type : 2,
		title : [title],
		maxmin: true, //开启最大化最小化按钮
        offset : [offset, ''],
        //iframe : {
            //src : url
        //},	
        content : url,
        area : [width+'px',height+'px'],
        close : function(index){
           if (closeCallback!=null && typeof(closeCallback)!='undefined') {
               closeCallback() ;
           }
		   parent.layer.close(index); 
	    },
	    success: function(layero){
	    	//$( ".layui-layer-iframe" ).resizable();
	    },
	    full: function(layero){
	    	debugger
	    	layer.getChildFrame('.mainlan').height('100%')
	    	layer.getChildFrame('.tabcontent').height('100%')
	    }
    });
}

function aryExist(str,ary,field){
	for(var i=0; i<ary.length; i++){
		if(str == ary[i][field]) return true;
	}
	return false;
}

function isArray(obj) {   
	 return Object.prototype.toString.call(obj) === '[object Array]';    
} 

function dateToStr(date, format)
{
	if(isObj(date.year) == false) return "";
	var year = (1900+parseInt(date.year)).toString();
	var o = {
		 "M+" : (parseInt(date.month)+1).toString(),	//month
		 "d+" : date.date,    //day
		 "H+" : date.hours,   //hour
		 "m+" : date.minutes, //minute
		 "s+" : date.seconds //second
	 };
	 if(/(y+)/.test(format)) 
		 format=format.replace(RegExp.$1,(year).substr(4 - RegExp.$1.length));
	
	 for(var k in o){
		 if(new RegExp("("+ k +")").test(format))
			 format = format.replace(RegExp.$1,RegExp.$1.length==1 ? o[k] :("00"+ o[k]).substr(o[k].length));
	 }
		 
	 return format;
}

String.prototype.trim=function() {
    return this.replace(/(^\s*)|(\s*$)/g,'');
};

function getRadioVal(rdName){
	var rds = $(":radio[name='"+rdName+"']");
	return valRadio(rds);
}

function valRadio(radios){
	for(var i=0; i<radios.length; i++){
		var radio = radios.eq(i);
		if(radio.attr("checked") == "checked"){
			return radio.val();
		}
	}
	return "";
}

function checkRadio(radios,value){
	for(var i=0; i<radios.length; i++){
		var radio = radios.eq(i);
		if(radio.val() == value){
			radio.attr("checked","checked");
			return;
		}
	}
}

function checkVal(obj){
	if(typeof(obj) == "string" && obj != "") return true;
	return false;
}

function adjustVal(obj){
	if(typeof(obj) == "undefined") return "";
	return obj;
}